import request from '@/axios'
import type { TableData } from './types'
import fileRequest from '@/axios/fileRequest'
// export const getTableListApi = (params: any) => {
//   return request.get({ url: '/mock/example/list', params })
// }

export const getTableListApi = (params: any) => {
  return request.get({ url: '/zjapi/user/getUserList', params })
}

export const getUserListApi = (params: any) => {
  return request.get({ url: '/zjapi/user/getUserList', params })
}

export const getClassNameApi = (params: any) => {
  return request.get({ url: '/zjapi/user/getClassName', params })
}

export const getCompanyApi = (params: any) => {
  return request.get({ url: '/zjapi/user/getCompany', params })
}

export const delClassNameApi = (params: any) => {
  return request.get({ url: '/zjapi/user/delClass', params })
}

export const editClassNameApi = (data: any) => {
  return request.post({ url: '/zjapi/user/editClass', data })
}

export const addClassNameApi = (data: any) => {
  return request.post({ url: '/zjapi/user/addClass', data })
}

export const getDeleteApi = (params: any) => {
  console.log(params)
  return request.get({ url: '/zjapi/user/delUser', params })
}

export const getCardTableListApi = (params: any) => {
  return request.get({ url: '/mock/card/list', params })
}

export const getTreeTableListApi = (params: any) => {
  return request.get({ url: '/mock/example/treeList', params })
}

export const saveTableApi = (data: Partial<TableData>): Promise<IResponse> => {
  return request.post({ url: '/mock/example/save', data })
}

export const getTableDetApi = (id: string): Promise<IResponse<TableData>> => {
  return request.get({ url: '/mock/example/detail', params: { id } })
}

export const getClassCount = (cid: string): Promise<IResponse<TableData>> => {
  return request.get({ url: '/zjapi/user/getClassCount', params: { cid } })
}

export const getCompanyList = (params: Object): Promise<IResponse<TableData>> => {
  return request.get({ url: '/zjapi/user/getCompany', params })
}

export const delTableListApi = (ids: string[] | number[]): Promise<IResponse> => {
  return request.post({ url: '/mock/example/delete', data: { ids } })
}

export const uploadFile = (File: Object): Promise<IResponse<TableData>> => {
  const formData = new FormData()
  formData.append('file', File)
  return fileRequest.post('/zjapi/user/upload', formData)
}

export const getCompanyAll = (params: Object): Promise<IResponse<TableData>> => {
  return request.get({ url: '/zjapi/user/getCompanyAll', params })
}
